{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-1-a475183c8241>, line 9)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-1-a475183c8241>\"\u001b[1;36m, line \u001b[1;32m9\u001b[0m\n\u001b[1;33m    |+ = len(f.readlines())\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "train_labled = df['label','text']\n",
    "train,test=train_test_split(train_labled,test_size=0.2,random_state=2021)\n",
    "train.to_csv('train.txt',index=False,header=Flase,sep='\\t')\n",
    "test.to_csv('test.txt',index=False,header=False,sep='\\t')\n",
    "txt_list=['train.txt','test.txt']\n",
    "l=0\n",
    "for file in txt_list:\n",
    "    with open(file,'r')as f:\n",
    "        |+ = len(f.readlines())\n",
    "print('拆分后的数据量为:',|)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "positional argument follows keyword argument (<ipython-input-2-5c8b8d4cd675>, line 15)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-2-5c8b8d4cd675>\"\u001b[1;36m, line \u001b[1;32m15\u001b[0m\n\u001b[1;33m    data_file-data_file,\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m positional argument follows keyword argument\n"
     ]
    }
   ],
   "source": [
    "from paddlehub.datasets.base_nip_dataset import TextClassificationDataset\n",
    "class MyDataset(TextClassificationDataset):\n",
    "    base_path='data'\n",
    "    label_list=['0.0','1.0','2.0','3.0','4.0','5.0','6.0','7.0']\n",
    "    def __init__(self,tokenizer,max_sep_len:int=128,mode:str='train'):\n",
    "        if mode=='train':\n",
    "            data_file='train.txt'\n",
    "        elif mode=='test':\n",
    "            data_file='dev.txt'\n",
    "        super(). __init__(\n",
    "            base_path=self.base_path,\n",
    "            tokenizer=tokenizer,\n",
    "            max_sep_len=max_sep_len,\n",
    "            mode=mode,\n",
    "            data_file-data_file,\n",
    "            label_list=self.label_list,\n",
    "            is_file_with_header=False)\n",
    "        model=hub.Module(name='ernie_tiny',task='seq-cls',num_classes=len(MyDataset.label_list))\n",
    "        tokenizer-mode.get_tokenizer()\n",
    "        train_dataset=MyDataset(tokenizer)\n",
    "        test_dataset=MyDataset(tokenizer,mode='test')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
